package com.ym.controller.medical;

import com.ym.core.annotation.Log;
import com.ym.core.domain.APIResponse;
import com.ym.core.domain.BaseController;
import com.ym.medical.domain.entity.UserCollectionEntity;
import com.ym.medical.service.IUserCollectionSV;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * 收藏有问诊记录，药品，器械，文章Controller
 * 
 * @author ym
 * @date 2020-09-04
 */
@Api(tags = "medical-收藏有问诊记录，药品，器械，文章")
@RestController("UserCollectionPcController")
@Validated
@RequestMapping("/medical/userCollection")
public class UserCollectionController extends BaseController {

    @Autowired
    private IUserCollectionSV userCollectionSV;

    @ApiOperation("获取收藏有问诊记录，药品，器械，文章详细信息")
    @Log(dataBase = false, printBody = false, printQuery = true)
    @GetMapping(value = "/info")
    public APIResponse<UserCollectionEntity> info(@RequestParam Long id) {
        UserCollectionEntity data = userCollectionSV.selectById(id);
        return successData(data);
    }

    @ApiOperation("删除收藏有问诊记录，药品，器械，文章")
    @Log(printQuery = false)
    @PostMapping("/delete")
    public APIResponse delete(@RequestBody @Valid @NotNull Long[] ids) {
        int result = userCollectionSV.deleteByIds(ids);
        return successData(result);
    }
}
